package com.decent.ejfadmin.finance.response.dto;

import com.decent.ejfadmin.common.bean.WithdrawRecord;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * @author zhangchao
 * @date 2018/7/27 15:53
 */
@Data
public class WithdrawRecordDto extends WithdrawRecord implements Serializable {

    private static final long serialVersionUID = 6858557826410747233L;

    private String userName;

    private String userAccount;
    /**
     * 认证姓名
     */
    private String certName;
    /**
     * 银行卡号
     */
    private String bankNo;
    /**
     * 银行卡盐值
     */
    private String bankSalt;
    /**
     * 支付宝
     */
    private String alipay;
    /**
     * 银行姓名
     */
    private String bankName;
    /**
     * 手续费
     */
    private BigDecimal servicePrice;
    /**
     * 打款方式
     */
    private String payType;

    /**
     * 提现渠道
     *
     * @param channel 提现渠道
     * @return
     */
    public static Integer getChannel(String channel) {
        //需要发往易缴费的提现记录列表
        switch (channel) {
            case "alipay":
                return 1;
            case "bank":
                return 0;
            default:
                return null;
        }
    }

    String getWithdrawStateFun(Integer withdrawStateFun) {
        switch (withdrawStateFun) {
            case 0:
                return "待获取";
            case 1:
                return "处理中";
            case 2:
                return "成功";
            case 3:
                return "失败";
            case 4:
                return "异常";
            case 5:
                return "返销";
            default:
                return "-";
        }
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder(100);
        sb.append("=\"").append(getOrderId()).append("\"");
        sb.append(",=\"").append(getFlowNo()).append("\"");
        sb.append(",=\"").append(getUserAccount()).append("\"");
        sb.append(",=\"").append(getUserName()).append("\"");
        sb.append(",=\"").append(getCertName()).append("\"");
        sb.append(",=\"").append(StringUtils.isBlank(getBankName()) ? "" : getBankName()).append("\"");;
        sb.append(",").append(getPrice());
        sb.append(",=\"").append(Integer.valueOf(0).equals(getApplytype()) ? "供卡余额提现" : "佣金提现").append("\"");
        sb.append(",=\"").append(Integer.valueOf(0).equals(getAuditstate()) ? "待审核" : Integer.valueOf(1).equals(getAuditstate()) ? "审核通过" : "审核失败").append("\"");
        sb.append(",=\"").append(getWithdrawStateFun(getState())).append("\"");
        sb.append(",=\"").append(DateFormatUtils.format(getStartTime(), "yyyy-MM-dd HH:mm:ss")).append("\"");
        sb.append(",=\"").append(DateFormatUtils.format(getEndTime(), "yyyy-MM-dd HH:mm:ss")).append("\"");
        sb.append(",").append(StringUtils.replace(getRemark(), ",", "，"));
        sb.append("\r\n");
        return sb.toString();
    }

}
